Java Database Programming with JDBC Java Database Programming with JDBC
by Pratik Patel
Coriolis, The Coriolis Group
ISBN: 1576100561   Pub Date: 10/01/96
  

Previous Table of Contents Next


Exceptions

Finally, we get to the exceptions. As with the other sections, the exception listings include a description and the class’ constructors and methods.

public class DataTruncation

This class extends SQLWarning. An exception is produced when data transfer is prematurely terminated on a write operation, and a warning is generated when data transfer is prematurely terminated on a read operation. You can use the methods contained here to provide debugging information because the JDBC driver should throw this exception when a data transfer problem is encountered.

Constructors

Constructor Additional Description
public DataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize) Builds a Throwable DataTruncation object with the specified properties

Methods

Method Name Additional Description
public int getDataSize() Returns the number of bytes that should have been transferred
public int getIndex() Returns the index of the column or parameter that was interrupted
public boolean getParameter() Returns true if the truncated value was a parameter, or false if it was a column
public boolean getRead() Returns true if truncation occurred on a read; false means truncation occurred on a write
public int getTransferSize() Returns the number of bytes actually transferred

public class SQLException

This class extends java.lang.Exception. It is the responsibility of the JDBC driver to throw this class when a problem occurs during an operation.

Constructors

These constructors are used to create an SQLException with the specified information. It is normally not necessary to create an exception unless the developer is working on creating a driver or higher level JDBC interface:

public SQLException()
public SQLException(String problem)
public SQLException(String problem, String SQLState)
public SQLException(String problem, String SQLState, int vendorCode)

Methods

Method Name Additional Description
public int getErrorCode() Returns the error code that was part of the thrown exception
public SQLException getNextException() Returns the next exception as an SQLException object
public String getSQLState() Returns the SQL state that was part of the thrown exception
public synchronized void setNextException (SQLException excp) Sets the next exception as excp for the SQLException object

public class SQLWarning

This class extends SQLException. It is the responsibility of the JDBC driver to throw this class when a problem occurs during an operation.

Constructors

These constructors build an SQLWarning object with the specified information. It is normally not necessary to create an SQLWarning unless the developer is working on creating a driver or higher level JDBC interface:

public SQLWarning()
public SQLWarning(String problem)
public SQLWarning(String problem, String SQLstate)
public SQLWarning(String problem, String SQLstate, int vendorCode)

Methods

Method Name Additional Description
public SQLWarning getNextWarning() Returns an SQLWarning object that contains the next warning
public void setNextWarning(SQLWarning warn) Sets the next SQLWarning warning warn for the SQLWarning object


Previous Table of Contents Next